package com.cm.figure.controller.user.userController;

import com.cm.figure.model.Data.Data;
import com.cm.figure.model.User;
import com.cm.figure.service.userService.UserService;
import com.cm.figure.utility.BuildData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * ClassName:UserController
 * Package:com.cm.figure.controller.user.userController
 * Description:
 *
 * @Date:2021/8/15 16:04
 * @com.chuangmei
 */
@Controller
@RequestMapping("/api/private/figure/")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/user/{userid}")
    @ResponseBody
    public Data user(@PathVariable Integer userid, HttpSession session) {

        // 响应数据
        Data data = new Data();
        if (null == userid) {
            data = BuildData.buildData(null,"查询用户失败 , 主键为空 , 请重试!",401);
        }

        User user = userService.queryUserByUserId(userid);
        if (null != user)
            data = BuildData.buildData(user, "查询成功!", 200);


        return data;
    }

}
